package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.StationEquipment;
import com.ruoyi.ftrl.service.IStationEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 换热站设备台账信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-24
 */
@RestController
@RequestMapping("/system/equipments")
public class StationEquipmentController extends BaseController
{
    @Autowired
    private IStationEquipmentService stationEquipmentService;

    /**
     * 查询换热站设备台账信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationEquipment stationEquipment)
    {
        startPage();
        List<StationEquipment> list = stationEquipmentService.selectStationEquipmentList(stationEquipment);
        return getDataTable(list);
    }

    /**
     * 导出换热站设备台账信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:export')")
    @Log(title = "换热站设备台账信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationEquipment stationEquipment)
    {
        List<StationEquipment> list = stationEquipmentService.selectStationEquipmentList(stationEquipment);
        ExcelUtil<StationEquipment> util = new ExcelUtil<StationEquipment>(StationEquipment.class);
        util.exportExcel(response, list, "换热站设备台账信息数据");
    }

    /**
     * 获取换热站设备台账信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stationEquipmentService.selectStationEquipmentById(id));
    }

    /**
     * 新增换热站设备台账信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:add')")
    @Log(title = "换热站设备台账信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationEquipment stationEquipment)
    {
        return toAjax(stationEquipmentService.insertStationEquipment(stationEquipment));
    }

    /**
     * 修改换热站设备台账信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:edit')")
    @Log(title = "换热站设备台账信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationEquipment stationEquipment)
    {
        return toAjax(stationEquipmentService.updateStationEquipment(stationEquipment));
    }

    /**
     * 删除换热站设备台账信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipments:remove')")
    @Log(title = "换热站设备台账信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stationEquipmentService.deleteStationEquipmentByIds(ids));
    }
}
